package com.guigu.basedservice.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.guigu.basedservice.entity.BaseCarBrand;
import com.guigu.basedservice.mapper.BaseCarBrandMapper;
import com.guigu.basedservice.service.BaseCarBrandService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.guigu.basedservice.vo.BaseCarBrandVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 品牌(车辆) 服务实现类
 * </p>
 *
 * @author Heyuhang
 * @since 2024-09-11
 */
@Service
public class BaseCarBrandServiceImpl extends ServiceImpl<BaseCarBrandMapper, BaseCarBrand> implements BaseCarBrandService {

    @Autowired(required = false)
    private BaseCarBrandMapper baseCarBrandMapper;

    @Override
    public PageInfo<BaseCarBrand> show2(BaseCarBrandVo vo,Integer currentPage, Integer pageSize) {
        QueryWrapper<BaseCarBrand> queryWrapper=new QueryWrapper<>();
        if (vo!=null) {
            if (vo.getName() != null && vo.getName() != "") {
                queryWrapper.eq("name", vo.getName());
            }
            if (vo.getType() != null && vo.getType() != "") {
                queryWrapper.eq("type", vo.getType());
            }
        }
        PageHelper.startPage(currentPage,pageSize);
        List<BaseCarBrand> list=baseCarBrandMapper.selectList(queryWrapper);
        PageInfo<BaseCarBrand> pageInfo=new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public BaseCarBrand selectType() {
        return baseCarBrandMapper.selectType();
    }

    @Override
    public BaseCarBrand addBaseCarBrand(BaseCarBrand baseCarBrand) {
        return baseCarBrandMapper.addBaseCarBrand(baseCarBrand);
    }
}
